<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        *{
            padding:0;
            margin:0
        }
        ul{
            width:100%;
            height:50px;
            position:absolute;
            display: flex;
            list-style: none;
            left:0;
            bottom:0;
            background:gray;
            border-top: 1px solid black;
        }
        li{
            text-align: center;
            line-height: 50px;
            flex: 1; 
        }
        .active{
            background:#fff;
        }
    </style>
</head>
<body>
    <div id="app">
        <div>
            <keep-alive>
            <component :is="page"></component>
            </keep-alive>
            <!-- 使用keep-alive标签可以在动态改变组件时不影响原组件的状态 -->
        </div>
        <footer>
            <div>
                <ul>
                    <li @click="page = 'mainPage' " :class="page == 'mainPage'? 'active' : '' " >首页</li>
                    <li @click="page = 'goods' " :class="page == 'goods' ? 'active' : '' " >商品</li>
                    <li @click="page = 'detail' " :class="page == 'detail' ? 'active' : '' " >详情</li>
                </ul>
            </div>
        </footer>
    </div>
    <script>
    Vue.component("mainPage",{
        template:`
            <div>
                首页
            </div>
        `,
    })
    Vue.component("goods",{
        template:`
            <div>
                商品
            </div>
        `,
    })
    Vue.component("detail",{
        template:`
            <div>
                详情
            </div>
        `,
    })
        const app = new Vue({
            el:"#app",
            data: {
                page:"mainPage"
            }

        });

    </script>
</body>
</html>